package com.demo.delivery;

import java.util.List;

import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class OrdersAdapter extends ArrayAdapter<Order> {
	private List<Order> orders;

	public Order getOrder(int position) {
		return orders.get(position);
	}

	public OrdersAdapter(Context context, List<Order> items) {
		super(context, R.layout.app_custom_list, items);
		this.orders = items;
	}

	@Override
	public int getCount() {
		return orders.size();
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View v = convertView;

		if (v == null) {
			LayoutInflater li = LayoutInflater.from(getContext());
			v = li.inflate(R.layout.app_custom_list2, null);
		}

		Order order = orders.get(position);

		if (order != null) {
			TextView name = (TextView) v.findViewById(R.id.name);

			name.setText(order.getClient_name());

			TextView cardNo = (TextView) v.findViewById(R.id.cardno);

			cardNo.setText(order.getCard_no());

			TextView status = (TextView) v.findViewById(R.id.status);

			status.setText(order.getStatus());

			ImageView call = (ImageView) v.findViewById(R.id.call);
			call.setTag(position);

		}

		return v;
	}
}